package com.xxx.rpc.common.bean;

/**
 * 封装 RPC 响应
 *
 * @author huangyong & Rosun
 * @since 1.0.0
 */
public class RpcResponse {

    private String requestId;
    private Exception exception;
    private Object result;
    private boolean isTimeOut = false;

    public boolean hasException() {
        return exception != null;
    }

    public String getRequestId() {
        return requestId;
    }

    public void setRequestId(String requestId) {
        this.requestId = requestId;
    }

    public Throwable getException() {
        return exception;
    }

    public void setException(Exception exception) {
        this.exception = exception;
    }

    public Object getResult() {
        return result;
    }

    public void setResult(Object result) {
        this.result = result;
    }
    
    @Override
    public String toString(){
    	StringBuffer sb = new StringBuffer();
    	sb.append("requestId=").append(requestId) ;
    	sb.append("    exception=").append(exception);
    	sb.append("    result=").append(result == null? "NULL" : result.getClass().getName());
    	return sb.toString();
    }

	/**
	 * @return the isTimeOut
	 */
	public boolean isTimeOut() {
		return isTimeOut;
	}

	/**
	 * @param isTimeOut the isTimeOut to set
	 */
	public void setTimeOut(boolean isTimeOut) {
		this.isTimeOut = isTimeOut;
	}
}
